import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
const store = new Vuex.Store({

    state: {
        userInfor: {},
        defaultSelectedKeys: [window.localStorage.getItem('key')],//默认key
        defaultOpenKeys: [window.localStorage.getItem('Levelkey')],//默认样式
        openKeys: [window.localStorage.getItem('Levelkey')],//默认展开

    },
    actions: {
        getkeys({ commit }) {
            let Levelkey = window.localStorage.getItem('Levelkey')
            let key = window.localStorage.getItem('key')

            // console.log(Levelkey, key)
            commit('setkeys', { Levelkey, key })
            // console.log()

        }


    },
    mutations: {
        setkeys(state, objkey) {
            // 重新赋值
            // console.log(objkey.Levelkey, objkey.key)
            state.defaultSelectedKeys = [`${objkey.Levelkey}`]
            state.defaultOpenKeys = [`${objkey.key}`]
            state.openKeys = [`${objkey.Levelkey}`]
        },
        setconfiguration(state, value) {
            state.openKeys = value
        },
    }

})


export default store

